from pymilvus import MilvusClient, DataType

client = MilvusClient(
    uri="http://localhost:19530",
    db_name="face_db"
)

schema = MilvusClient.create_schema(
    auto_id=False,
    enable_dynamic_field=True,
)

schema.add_field(field_name="user_id",
                 datatype=DataType.INT64, is_primary=True)
schema.add_field(field_name="face_info",
                 datatype=DataType.FLOAT_VECTOR, dim=128)

index_params = client.prepare_index_params()

index_params.add_index(
    field_name="user_id",
    index_type="STL_SORT"
)

index_params.add_index(
    field_name="face_info",
    metric_type="COSINE",
    index_type="IVF_FLAT",
    index_name="face_info_index",
    params={ "nlist": 128 }
)

client.create_collection(
    collection_name="face_collection",
    schema=schema,
    index_params=index_params
)

res = client.get_load_state(
    collection_name="face_collection"
)

print(res)
